package com.chao.mail.core

import com.chao.mail.core.interfaces.IMailRepository
import com.chao.mail.core.interfaces.IMailSender
import org.springframework.web.multipart.MultipartFile
import java.util.*

class Mail(
        var id: String? = null,
        val from: String,
        val to: String,
        val subject: String,
        val text: String,
        var sentDate: Date? = Date(),
        var cc: String? = null,
        var bcc: String? = null,
        var multipartFiles: Array<MultipartFile>?
) {
    var mailSender: IMailSender? = null
    var mailRepository: IMailRepository? = null
    var status: MailStatus = MailStatus.UN_SEND

    fun sendMail() {
        mailSender?.sendMail(this)
    }

    fun saveMail(){
        mailRepository?.insertMail(this)
    }
}